<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Recruit extends BaseModel
{
    protected $table = 'recruit';

    protected $casts = [
        'salary_info' => 'array'
    ];

    /**
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    /**
     * 一个人也可以收藏多个工作，一个工作可以被多个人收藏
     * @return BelongsToMany
     */
    public function collectedByUsers(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'user_collect_recruit', 'recruit_id', 'user_id');
    }

   /* public function getStatusAttribute($status): string
    {
        return match ($status) {
            -1 => '已删除',
            -2 => '管理员禁用',
            1 => '审核中',
            2 => '招工中',
            3 => '已招满',
            4 => '未通过',
        };
    }*/
}
